﻿using System;
using System.Collections.Generic;

using System.Text;
using Estimate.Common.DataFileFinder;
using Estimate.Common.DataImporter;
using System.Configuration;
using System.IO;
using Estimate.Common.Estimate;
using Estimate.Common.Entity;
using Estimate.Common.DBFieldTypes;
using Estimate.Common.Repository;
using Estimate.Common;
using log4net;
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
namespace Estimate.AutoInDatabae
{
    class Program
    {

        static void Main(string[] args)
        {
            ILog Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            DataImporterCombiner combiner = new DataImporterCombiner(ConfigurationManager.AppSettings);
            try
            {

                //手动站数据是按月导入的
                string manualDate = ConfigurationManager.AppSettings["ManualImportDate"];
                if (DateTime.Now.Day == Convert.ToInt32(manualDate))
                {
                    DateTime twoMonthAgo = DateTime.Now.AddMonths(-2);
                    combiner.importManualData(twoMonthAgo.Year, twoMonthAgo.Month, twoMonthAgo.Year, twoMonthAgo.Month);
                }

                //查询实况数据中，需要重新导入的数据
                combiner.reimportInvalideData();

                combiner.execute(DateTime.Now);

            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
           


        }

    }
}
